package controller;

import dao.CodeValidateDao;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet(name = "validateCodeServlet", value = "/validateCode")
public class ValidateCodeServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CodeValidateDao codeValidateDao = new CodeValidateDao();
        codeValidateDao.getCode(request, response);
        request.setAttribute("codeValidate", codeValidateDao);
        request.getRequestDispatcher("codeValidateImg").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
